package com.venom.pizza.repositories;

import com.venom.pizza.entities.Category;
import java.util.List;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

/**
 *
 * @author denis
 */
// Default is read only
@Transactional
@Repository
public class CategoryRepositoryImpl implements CategoryRepository {
    private HibernateTemplate hibernateTemplate;
    
    @Autowired
    public void setSessionFactory(SessionFactory sessionFactory) {
        hibernateTemplate = new HibernateTemplate(sessionFactory);        
    }

    @Override
    public List<Category> fetchAll() {
        return hibernateTemplate.find("from " + Category.class.getName());
    }
    
}
